package com.htu.tax.controller;

import com.htu.tax.common.ResponseHelper;
import com.htu.tax.common.ResponseModel;
import com.htu.tax.payload.request.Driver.AddDriverRequest;
import com.htu.tax.payload.request.Driver.ChangeDriverRequest;
import com.htu.tax.payload.request.Driver.SelectDriverRequest;
import com.htu.tax.payload.request.Driver.UpdateDriverRequest;
import com.htu.tax.service.DriverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "司机信息")
@RestController
@RequestMapping("/driver")
public class DriverController {
    @Resource
    private DriverService driverService;

    @ApiOperation("添加司机")
    @PostMapping("/addDriver")
    public ResponseModel addDriver(@RequestBody AddDriverRequest request) {
        return driverService.addDriver(request);
    }

    @ApiOperation("查询司机")
    @PostMapping("/selectDriver")
    public ResponseModel selectDriver(@RequestBody SelectDriverRequest request) {
        return ResponseHelper.buildResponseModel(driverService.selectDriver(request));
    }

    @ApiOperation("修改司机")
    @PostMapping("/updateDriver")
    public ResponseModel updateDriver(@RequestBody UpdateDriverRequest request) {
        driverService.updateDriver(request);
        return ResponseHelper.buildResponseModel("修改成功");
    }

    @ApiOperation("改变状态")
    @PostMapping("changeDriverState")
    public Integer changeDriverState(@RequestBody ChangeDriverRequest request) {
        return driverService.changeDriverState(request);
    }

}

